package org.jeecg.modules.yw.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.SysAnnouncement;
import org.jeecg.modules.yw.vo.SysAnnoucementVo;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

@Mapper
public interface SysannoucementMapper extends BaseMapper<SysAnnouncement>  {
	/**
	 * 查询注册信息多少数
	 * @return
	 */
	@Select("select count(1) cnt, roleId from enterprise where (isLeader is null or isLeader = 0 or isLeader = 1) and (approve is null or approve = 0) and delFlag = 0 group by roleId")
	public List<Map<String, String>> getEnterpriseCount();
	
	/**
	 * 查询新建订单有多少
	 * @return
	 */
	@Select("select count(1) cnt from `order` where delFlag = 0 and orderStatus = 0 ")
	public Integer getNewOrderCnt();
	
	
	
	/**
	 * 查询消息有多少
	 * @return
	 */
	@Select("select count(1) cnt, msg_type msgType from sys_announcement where del_Flag = 0 and msg_type is not null group by msg_type")
	public List<Map<String, String>> getMessageCnt();
	/**
	 * 
	 * @param page
	 * @param queryWrapper
	 * @return
	 */
    IPage<SysAnnoucementVo> msgEnter(Page<SysAnnoucementVo> page, @Param(Constants.WRAPPER) QueryWrapper<SysAnnoucementVo> queryWrapper);
    
    
	/**
	 * 更新消息
	 * @return
	 */
	@Select("update sys_announcement set del_flag = '1' where id=#{id}")
	public int updateMsg(@Param("id") String id);
	
	
	/**
	 * 查询打胶待接收有多少
	 * @return
	 */
	@Select("select count(1) from sys_announcement where del_Flag = 0 and msg_category = 11 and bus_id=#{busiId}")
	public Integer getDjShJjMessageList(@Param("busiId") String busiId);
	
	
	/**
	 * 更新(已读)消息
	 * @return
	 */
	@Select("update sys_announcement_send set read_flag = '1' where annt_id in (select id from sys_announcement where bus_id = #{id})")
	public int updateRead(@Param("id") String id);
	
	
}
